<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path=request.getContextPath();
	String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>   
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>>"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
	<style>
		body{
			font-size:14px;
			
		}
		table.altrowstable {
	    qont-family: verdana,arial,sans-serif;
		    font-size:14px;
		    border-width: 1px;
		    border-color: #a9c6c9;
		    border-collapse: collapse;
		    width: 500px;
		    height: 50px;
		    text-align:center;
		}
		table.altrowstable th {
		    border-width: 1px;
		    padding: 8px;
		    border-style: solid;
		    border-color: #131a1b;
		}
		table.altrowstable td {
		    border-width: 1px;
		    padding: 8px;
		    border-style: solid;
		    border-color: #131a1b;
		}
		.oddrowcolor{
		    background-color:#d4e3e5;
		}
		.evenrowcolor{
		    background-color:#c3dde0;
		}
	</style>
</head>
<body>
	<form action="">
		<div align="center">
		<table  class="altrowstable" id="alternatecolor">
			<tr><th></th><th>姓名</th><th>性别</th><th>电话</th></tr>
			<c:forEach var="item" items="${query}">
				<tr>
					<td><input type="checkbox" class="userId" name="iUserId" value="${item.iUserId}"/></td>
					<td>${item.sName}</td>
					<td><c:if test="${item.sSex==2}">男</c:if><c:if test="${item.sSex==3}">女</c:if></td>
					<td>${item.sTel}</td>
				</tr>
			</c:forEach>
			<tr ><td colspan="4">
				<a href = "manager/allquery.action?page=1" >首页</a>  
				<a href = "manager/allquery.action?page=${manager.page-1}" id="">上一页</a>  
				<a href = "manager/allquery.action?page=${manager.page+1}">下一页</a>  
				<a href = "manager/allquery.action?page=${manager.pages}">尾页</a> 
				第${manager.page}页/共 ${manager.pages}页 
			</td></tr>
			<tr class="tr1">
					
					<td colspan="5">
						<input type="button" value="修改" onclick="doUpdate()" style="opacity: 0.5"/>
						<input type="button" value="删除" onclick="doDetele()" style="opacity: 0.5"/>
						<input type="button" value="增加" onclick="window.location='manager/query.action?sMethod=getNation'" style="opacity: 0.5"/>
						<input type="reset" value="重置" onclick="window.location='manager/allquery.action'" style="opacity: 0.5"/>
					</td>
				</tr>
		</table>
		</div>
	</form>
</body>
	<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
	<script type="text/javascript">

	function doUpdate(){
		if(0==$(".userId:checked").length){
			alert("请选择要修改的项");
			return false;
		}else if(1!=$(".userId:checked").length){
			alert("只能选择一项进行修改");
			return false;
		}
		var str = "manager/query.action?sMethod=toUpdate&iUserId=" + $(".userId:checked").val();
		window.location=str;
	}
	function doDetele(){
		if(0==$(".userId:checked").length){
			alert("请选择要修改的项");
			return false;
		}
		var str="manager/delete.action?";
		
		for(var i=0;i<$(".userId:checked").length;i++){
			str+="iUserIds="+$(".userId:checked").eq(i).val();
			if($(".userId:checked").length-1!=i){
				str+="&";
			}
		}
		window.location=str;
	}
	</script>
</html>